 
 *******************
* Exporting table for Global South COVID paper
* 2020-06-13
* last updated: 2020-09-09
* Magdalena Larreboure
*******************

set more off
gl weight hh_weight

use "$da/KEN1_maintable.dta" , clear

loc outcomes incomedrop employmentdrop accessmarkets missedmeals anysupport


********************************************************************************************************
********************************************************************************************************
********************************************************************************************************

local sR *
local sig1 `sR'
local sig2 `sR'`sR'
local sig3 `sR'`sR'`sR'
local formatDisp %10.2f

	
*Complete sample
	foreach var of varlist `outcomes' {
	qui sum `var' [aw=$weight]
	loc mpost=`r(mean)'
	loc mpost_`var'_all1:  di %10.2fc r(mean)
	loc `var'_SD :  di %10.2fc r(sd)
	loc sdpr_`var'_all1 "(``var'_SD')"
	loc n_`var'_all1:  di %10.0fc r(N)
	
*Heterogeneity dimensions
	
	foreach het in "b_cons" { 
	forval i=0/1 {
	qui sum `var' [aw=$weight] if `het'==`i'
	loc mpost=`r(mean)'
	loc mpost_`var'_`het'`i':  di %10.2fc r(mean)
	loc `var'_SD :  di %10.2fc r(sd)
	loc sdpr_`var'_`het'`i' "(``var'_SD')"
	loc n_`var'_`het'`i':  di %10.0fc r(N)

	}
	}
	}
		

	clear all
	set obs 3
	g full_sample=0
	replace full_sample = 1 in 1	
	g below_consumption=0
	replace below_consumption = 1 in 2
	g above_consumption=0
	replace above_consumption = 1 in 3

	
	foreach var in "incomedrop" "employmentdrop" "accessmarkets" "healthaccess" "missedmeals" "anysupport" { 

		g post_`var'   = ""	
			
	
			replace post_`var'   = "`mpost_`var'_b_cons1'" if below_consumption==1
			replace post_`var'   = "`mpost_`var'_b_cons0'" if above_consumption==1
			replace post_`var'   = "`mpost_`var'_all1'" if full_sample==1
	
	}
	
		g n=""
		replace n = "`n_anysupport_all1'" in 1
		replace n = "`n_anysupport_b_cons1'" in 2
		replace n = "`n_anysupport_b_cons0'" in 3

	
	drop below_consumption above_consumption full_sample
 	export excel using "$dtab/Main Table.xlsx", sheetmodify cell(B34)
